<?php
include("db_config.php");
if(isset($_POST["MessageBlock"])){
// parse message block and extract software_id

$message = json_decode(stripslashes($_POST["MessageBlock"]));
$temp=$message->{"serviceMode"};
if($temp == "DESTROY"){
$temp1=$message->{"data"};
foreach($temp1 as $key => $value)
{
	$software_id=$value;
}
$con = mysql_connect($db_host,$db_user,$db_password);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  
mysql_select_db($db_name, $con);

$result = mysql_query("SELECT id FROM software where software_key='".$software_id."';");
$row = mysql_fetch_array($result);
mysql_query("delete from audit where software_id=".$row['id']." and action='TOKEN-IO:ACCESS';");
mysql_close($con);
}
}

?>